package book_management.operation.impl;

import book_management.book.Book;
import book_management.book.BookList;
import book_management.operation.IOperation;

public class AddOperation implements IOperation {
    //添加书籍操作接口
    @Override
    public void work(BookList bookList) {
        System.out.println("您现在进行添加书籍操作.");
        System.out.println("请输入添加书名:");
        String bookName = scanner.next();
        //判断书记是否存在
        if (bookList.contains(bookName)) {
            System.out.println("当前书籍已存在！！！");
            return;
        }
        System.out.println("请输入作者");
        String author = scanner.next();
        System.out.println("请输入价格");
        Double price = scanner.nextDouble();
        System.out.println("请输入类别");
        String type = scanner.next();
        Book book = new Book(bookName, author, price, type);
        bookList.add(book);
        System.out.println("添加成功！");
    }
}
